What is faster: multiple `send`s or using buffering?
Posted
by dauerbaustelle
on Stack Overflow
See other posts from Stack Overflow
or by dauerbaustelle
Published on 2010-04-14T15:04:48Z
Indexed on
2010/04/14
15:13 UTC
Read the original article
Hit count: 210
I'm playing around with sockets in C/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket.
My ideas:
- use a
send
call for every header. Pros: No memory allocation needed. Cons: manysend
calls -- probably error prone; error management should be rather complicated - use a buffer. Pros: one
send
call, error checking a lot easier. Cons: Need a buffer :-)malloc
/realloc
should be rather slow and using a (too) big buffer to avoidrealloc
calls wastes memory.
Any tips for me? Thanks :-)
© Stack Overflow or respective owner